package com.triptogether.baseclasses;

import java.util.Calendar;

import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.os.Bundle;


public class DateTimeDialog extends TripTogetherDialog {
	
	private OnDateSetListener onDateSetListener;
	
	public DateTimeDialog(String title, OnDateSetListener onDateSetListener) {
		super(title, "");
		this.onDateSetListener = onDateSetListener;
	}
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

        // Create a new instance of DatePickerDialog and return it
        DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), onDateSetListener, year, month, day);
        datePickerDialog.setTitle(this.title);
        datePickerDialog.setCancelable(true);
        datePickerDialog.setCanceledOnTouchOutside(true);
        
        return datePickerDialog;
	}
}